//
//  MineFuncItemVM.swift
//  kxf
//
//  Created by Mac on 2024/3/5.
//

import Foundation
import UIKit

class MineFuncItemVM: UIView {
    
    let selfWidth = kFitWidth(343)
    let selfHeight = kFitWidth(56)
    
    var tapBlock:(()->())?

    override init(frame:CGRect){
        super.init(frame: CGRect.init(x: 0, y: frame.origin.y, width: selfWidth, height: selfHeight))
        self.backgroundColor = .white
        self.isUserInteractionEnabled = true
        
        let tap = UITapGestureRecognizer.init(target: self, action: #selector(tapAction))
        self.addGestureRecognizer(tap)
        
        initUI()
    }
    required init?(coder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    lazy var titleLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = .black
        lab.font = .systemFont(ofSize: 16, weight: .medium)
        
        return lab
    }()
    lazy var rightLabel : UILabel = {
        let lab = UILabel()
        lab.textColor = .COLOR_TEXT_BLACK666
        lab.font = .systemFont(ofSize: 14, weight: .regular)
        
        return lab
    }()
    lazy var arrowImgView : UIImageView = {
        let img = UIImageView()
        img.image = UIImage.init(named: "login_arrow_img")
        img.isUserInteractionEnabled = true
        
        return img
    }()
    lazy var lineView : UIView = {
        let vi = UIView()
        vi.backgroundColor = .COLOR_LIGHT_GREY
        
        return vi
    }()
}

extension MineFuncItemVM{
    @objc func tapAction() {
        if self.tapBlock != nil{
            self.tapBlock!()
        }
    }
}
extension MineFuncItemVM{
    func initUI() {
        addSubview(titleLabel)
        addSubview(rightLabel)
        addSubview(arrowImgView)
        addSubview(lineView)
        
        setConstrait()
    }
    func setConstrait() {
        titleLabel.snp.makeConstraints { make in
            make.left.equalTo(kFitWidth(21))
            make.centerY.lessThanOrEqualToSuperview()
        }
        arrowImgView.snp.makeConstraints { make in
            make.right.equalTo(kFitWidth(-12))
            make.centerY.lessThanOrEqualToSuperview()
            make.width.height.equalTo(kFitWidth(20))
        }
        rightLabel.snp.makeConstraints { make in
            make.right.equalTo(arrowImgView.snp.left).offset(kFitWidth(-5))
            make.centerY.lessThanOrEqualTo(arrowImgView)
        }
        lineView.snp.makeConstraints { make in
            make.left.width.bottom.equalToSuperview()
            make.height.equalTo(kFitWidth(0.3))
        }
    }
}
